const {
  DataTypes
} = require('sequelize');

const seq = require('../db/seq');
const Paster = require('../model/paster');
const paster = Paster(seq);

module.exports = sequelize => {
  const attributes = {
    id: {
      type: DataTypes.INTEGER,
      allowNull: false,
      defaultValue: null,
      primaryKey: true,
      autoIncrement: true,
      comment: null,
      field: "id"
    },
    user_id: {
      type: DataTypes.STRING(255),
      allowNull: true,
      defaultValue: null,
      primaryKey: false,
      autoIncrement: false,
      comment: null,
      field: "user_id"
    },
    paster_id: {
      type: DataTypes.INTEGER,
      allowNull: true,
      defaultValue: null,
      primaryKey: false,
      autoIncrement: false,
      comment: null,
      field: "paster_id"
    },
    paster_type: {
      type: DataTypes.INTEGER,
      allowNull: true,
      defaultValue: null,
      primaryKey: false,
      autoIncrement: false,
      comment: null,
      field: "paster_type"
    }
  };
  const options = {
    tableName: "user_paster",
    comment: "",
    indexes: []
  };
  const UserPasterModel = sequelize.define("user_paster_model", attributes, options);
  UserPasterModel.belongsTo(paster, {
    foreignKey: 'paster_id',
    as: 'paster_info',
  })
  return UserPasterModel;
};